from selenium import webdriver
import time

from selenium.webdriver.common.by import By

wd = webdriver.Chrome()
url = 'http://www.baidu.com'
wd.get(url)
time.sleep(3)
shuzi =wd.find_element(By.ID,'kw').send_keys("史迪奇")
time.sleep(3)
dianji =wd.find_element(By.ID,'su').click()
#滚轮
gunlong='document.documentElement.scrollTop=100000'
wd.execute_script(gunlong)
time.sleep(3)
#下一页
xiayiye =wd.find_element(By.XPATH,'//*[@id="page"]/div/a[1]/span').click()
time.sleep(3)
#前进
wd.back()
time.sleep(3)
#后退
wd.forward()
time.sleep(3)
#打印源码
print(wd.page_source)